package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

//向文本写入文本数据
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("fos.txt");//这里也可以追加用append(true)
        /*
        String line = "我独揽10注双色球一等奖";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
                或者↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓更简洁
         */
        fos.write("我独揽10注双色球一等奖".getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕!");
        fos.close();
    }
}
